<template>
	<div>
		<m-table name="admin-feedback" :action="action" :search="search" ref="table">
			<el-table-column label="反馈账户" width="150" prop="userName" />

			<el-table-column label="联系方式" width="150" prop="userPhone" />

			<el-table-column label="所属商户" prop="storeName" width="180" />

			<el-table-column label="反馈内容" prop="content" width="180" />

			<el-table-column label="客服反馈" prop="adminMemo" width="180" />

            <el-table-column label="处理人" prop="adminName" width="180" />

			<el-table-column label="反馈时间" prop="created" width="220" />

            <el-table-column label="处理时间" prop="adminTime" width="220" />

			<el-table-column label="状态">
				<template slot-scope="scope">
					<el-tag :type="scope.row.state == 0 ? 'info' : scope.row.state == 1 ? 'success' : 'danger'" class="tag">{{
						state[scope.row.state]
					}}</el-tag>
				</template>
			</el-table-column>

			<el-table-column label="操作" prop="state" width="90" fixed="right">
				<el-button size="mini" @click="handerAllocation(scope.row)" slot-scope="scope">处理</el-button>
			</el-table-column>
		</m-table>

		<el-dialog title="处理" :visible.sync="feedback.show" width="320px">
			<el-form>
				<el-form-item label="">
					<el-radio-group v-model="feedback.data.state">
						<el-radio :label="1">已处理</el-radio>
						<el-radio :label="2">无效反馈</el-radio>
					</el-radio-group>
				</el-form-item>

				<el-form-item label="">
					<el-input placeholder="请输入反馈内容" v-model="feedback.data.adminMemo" type="textarea" :row="2"></el-input>
				</el-form-item>

			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submit">确 定</el-button>
			</span>
		</el-dialog>
	</div>
</template>
    
<script>
import request from '@/utils/request';
const states = [{ id : 0 , name : '未处理' },{ id : 1, name : '已处理' },{ id : 2, name : '无效反馈' }]
export default {
	data() {
		return {
			state: ['未处理', '已处理', '无效反馈'],
			//分配客服
			feedback: {
				show: false,
				data: {
					id: 0,
					state: 0,
					adminMemo: '',
				},
			},
			search: [
				{ icon: 'el-icon-mobile', type: 'select', name: 'a.state', label: '处理结果', span: 4, value: '' , data: states },
			],
			action: { remove: false, edit: false, add: false, export: false },
		};
	},
	methods: {
		handerAllocation(e) {
			this.feedback.data.id = e.id;
			this.feedback.show = true;
		},
		async submit() {
			await request.post(`admin-feedback/handler`, this.feedback.data);

			this.$message.success('操作成功');

			this.feedback.show = false;

            this.$refs.table.reload();
		},
	},
};
</script>
    
    <style>
.tag {
	font-size: 10px !important;
}
</style>